<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>主界面</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-2.1.0.js"></script>
<script type="text/javascript">
	$(function() {
		$("#btn").click(function() {
				$.ajax({
						url : "${pageContext.request.contextPath }/showTelBook?uid=${sessionScope.user.uid }",
						type : "post",
						cache : "false",
						dataType : "json",
						async : "true",
						success : function(data) {
							var str = "";
							for (var i = 0; i < data.length; i++) {
							str+="<tr><td>"+data[i].tid+"<td/><td>"+data[i].tname+"<td/><td>"+data[i].uid+"<td/>";
							str+="<td><button><a href=\"${pageContext.request.contextPath }/showContact?uid="+data[i].uid+"&tid="+data[i].tid+"\">查看联系人</a></button><td/><tr/>";
			
									}
							$("#tbody").html(str);
									},
							error : function() {
								$("#tbody").html("服务器错误")
									}
								});
					});
	});
</script>
</head>
<body>
	<div>
		<c:if test="${sessionScope.user != null }">
			<span style="color: blue">欢迎${user.uname}登录</span>
			<br />
			<br />
			<br />
			<div>
			<form action="serchContact?uid=${user.uid}" method="post">
			<span>请输入要查询的联系人:</span><input type="text" name="cname" /><br>
			<input type="submit" value="查询"/>
			</form>
			</div>
			<br>
			<br>
			<br>
			<button id="btn">查看通讯录</button>
			<div>
				<table>
					<thead>
						<tr>
							<th>TID
							<th />
							<th>通讯录类型
							<th />
							<th>UID
							<th />
							<th rosplan="3">
							功能
							<th/>
						<tr />
					<thead />
					<tbody id="tbody">

					</tbody>
				</table>
			</div>
			<br>
			<br>
			<br>
		<div>
		<form action="loginOut" method="post">
		<input type="submit" value="退出"/>
		</form>
		</div>
		</c:if>
		<c:if test="${sessionScope.user = null }">
			<%
				request.setAttribute("error", "请不要非法访问");
					request.getRequestDispatcher("/jsp/login.jsp").forward(request, response);
			%>
		</c:if>
	</div>
</body>
</html>